//
//  HTTPClient.h
//  Pure Dates
//
//  Created by Jiang on 2018/3/20.
//  Copyright © 2018年 Jiang. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "HTTPPlugin.h"

typedef enum{
    GET = 0,
    POST
}SFNHTTPMethod;
NS_ASSUME_NONNULL_BEGIN
typedef void(^HTTPHandler)(NSHTTPURLResponse *response, id _Nullable data ,NSError *_Nullable error);

@interface HTTPClient : NSObject
@property (nonatomic,readonly) NSURL *baseUrl;
- (instancetype)initWithBaseUrl:(NSURL *)baseUrl;

- (NSURLSessionDataTask *)requestWithMethod:(SFNHTTPMethod)method
                                        uri:(NSString *)uri
                                 parameters:(nullable NSDictionary *)param
                                    plugin:(nullable id <SFNPlugin>)plugin
                                 completion:(HTTPHandler)completion;

//生成request
- (NSMutableURLRequest *)createRequestWithMethod:(SFNHTTPMethod)method
                                             uri:(NSString *)URLString
                                      parameters:(nullable NSDictionary *)param;

- (NSMutableURLRequest *)createEncryptedRequestWithMethod:(SFNHTTPMethod)method
                                                      uri:(NSString *)URLString
                                               parameters:(nullable NSDictionary *)param;


- (NSURLSessionDataTask *)request:(NSURLRequest *)request
                          plugin:(nullable id <SFNPlugin>)plugin
                       completion:(HTTPHandler)completion;



@end
NS_ASSUME_NONNULL_END
